package com.tt.fashionWebSite.controller;

import com.tt.fashionWebSite.dao.ThongTinThanhVienDao;
import com.tt.fashionWebSite.dto.*;
import com.tt.fashionWebSite.service.HeaderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;
import java.util.List;

/**
 * Created by 10520_000 on 11/4/14.
 */
@Controller
//@RequestMapping(value = "/header")
public class HeaderController {

//    @SuppressWarnings("rawtypes")
//    @RequestMapping(value = "/register", method = RequestMethod.GET)
//    public ModelAndView loadRegisterPage() {
//        return new ModelAndView("user/user-register");
//    }
    @Autowired
    private HeaderService headerService;

    @SuppressWarnings("rawtypes")
    @RequestMapping(value = "/header/register", method = RequestMethod.POST)
    public @ResponseBody JsonResponseDto<PhanQuyenDto> emailContact(HttpServletRequest request, @RequestBody PhanQuyenDto userDto) {
       return new JsonResponseDto<PhanQuyenDto>(headerService.insertInfoUser(userDto), JsonResponseCode.SUCCESS);
    }

   @SuppressWarnings("rawtypes")
   @RequestMapping(value = "/header/login", method = RequestMethod.POST)
   public @ResponseBody JsonResponseDto<LoginDto> userLogin(HttpServletRequest request, @RequestBody LoginDto loginDto) {
      return new JsonResponseDto<LoginDto>(headerService.userLogin(loginDto), JsonResponseCode.SUCCESS);
   }

   @SuppressWarnings("rawtypes")
   @RequestMapping(value = "admin/header/login", method = RequestMethod.POST)
   public @ResponseBody JsonResponseDto<LoginDto> adminLogin(HttpServletRequest request, @RequestBody LoginDto loginDto) {
      return new JsonResponseDto<LoginDto>(headerService.userLogin(loginDto), JsonResponseCode.SUCCESS);
   }
}
